package io.coderyeah.order.controller;

import io.coderyeah.basic.Result;
import io.coderyeah.order.dto.OrderDTO;
import io.coderyeah.order.service.OrderPetAcquisitionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lqs
 * @date 2022/9/29 16:13
 */
@RestController
@RequestMapping("/orderPetAcquisition")
public class AcquisitionOrderController {
    @Autowired
    private OrderPetAcquisitionService acquisitionService;

    @PostMapping("/list")
    public Result list(@RequestBody OrderDTO orderDTO) {
        return acquisitionService.getAll(orderDTO);
    }

    @PostMapping
    public Result list(@RequestBody OrderDTO orderDTO, HttpServletRequest request) {
        return acquisitionService.getAll(orderDTO, request);
    }

    /**
     * 确认订单
     *
     * @param orderDTO
     * @return
     */
    @PostMapping("/confirm")
    public Result confirm(@RequestBody OrderDTO orderDTO) {
        return acquisitionService.confirm(orderDTO);
    }

    @PostMapping("/cancel/{id}")
    public Result cancel(@PathVariable("id") Long id) {
        return acquisitionService.cancel(id);
    }
}
